package leetcode.简单;

import leetcode.entity.TreeNode;
import leetcode.utils.TreeNodeUtils;
import org.junit.Test;

public class leetcode100_相同二叉树 {


    @Test
    public void test(){
        TreeNode treeNode1 = TreeNodeUtils.createTreeNode(5);
        TreeNode treeNode2 = TreeNodeUtils.createTreeNode(4);

        System.out.println(isSameTree(treeNode1,treeNode2));
    }



    public boolean isSameTree(TreeNode p,TreeNode q){
        if (p==null && q == null){
            return true;
        }else if (p==null ||q==null){
            return false;
        }else if (p.val != q.val){
            return false;
        }else {
            return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
        }
    }


}
